﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:presence="clr-namespace:Microsoft.Samples.Office.UnifiedCommunications.PresenceControls;assembly=WPFMOCPresenceControls"
    xmlns:UCOCS_Gadget="clr-namespace:Microsoft.Samples.Office.UnifiedCommunications.Gadget" 
                    xmlns:d="http://schemas.microsoft.com/expression/blend/2006" 
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                    mc:Ignorable="d">

    <DataTemplate x:Key="GadgetListFav5">
		<Grid>			
			<Rectangle Stroke="#FF161D25" x:Name="rect" Visibility="Collapsed" Width="125">
				<Rectangle.Fill>
					<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
						<GradientStop Color="#FF45484C" Offset="1"/>
						<GradientStop Color="#FF5D5D69" Offset="0"/>
						<GradientStop Color="#FF1E2333" Offset="0.536"/>
						<GradientStop Color="#FF3F3F4D" Offset="0.504"/>
					</LinearGradientBrush>
				</Rectangle.Fill>
			</Rectangle>			
			<StackPanel Orientation="Horizontal" Margin="0,2.5,0,2.5">
				<presence:Persona x:Name="personaFav5" SipUri="{Binding Path=SipUri}" ShowToolTip="True" 
                                  ShowDetailedToolTipText="False" Margin="3,0,4,0"
                                  UseXAMLPresenceImages="True" Height="16" Width="16"/>
				<TextBlock  x:Name="tbFav5DisplayName" Text="{Binding Path=DisplayName}" FontSize="11" FontFamily="Calibri" VerticalAlignment="Center" Foreground="#FFF"/>
			</StackPanel>            
	    </Grid>
    	<DataTemplate.Triggers>   
            <DataTrigger Binding="{Binding 
                                    Path=IsSelected, 
                                    RelativeSource=
                                    {
                                       RelativeSource 
                                       Mode=FindAncestor, 
                                       AncestorType={x:Type ListBoxItem}
                                    }
                                  }"  Value="true">
                <Setter TargetName="rect" Property="Visibility" Value="Visible" />
                <Setter TargetName="rect" Property="Opacity" Value=".45" />
            </DataTrigger>            
            <Trigger Property="IsMouseOver" Value="True">
                <Setter TargetName="rect" Property="Visibility" Value="Visible" />
            </Trigger>
        </DataTemplate.Triggers>
	</DataTemplate>
	
    <DataTemplate x:Key="GadgetListTop5">
        <Grid>
            <StackPanel Orientation="Horizontal">
                <presence:Persona x:Name="personaTop5" SipUri="{Binding Path=SipUri}" ShowToolTip="True" 
                                  ShowDetailedToolTipText="False" Margin="3,0,4,0"
                                  UseXAMLPresenceImages="True" Height="16" Width="16"/>
                <TextBlock x:Name="tbTop5DisplayName" Text="{Binding Path=DisplayName}" FontSize="12" FontFamily="Arial" VerticalAlignment="Center"/>
    	  </StackPanel>
        </Grid>
    </DataTemplate>




    <Style x:Key="ExpanderHeaderFocusVisual">
		<Setter Property="Control.Template">
			<Setter.Value>
				<ControlTemplate>
					<Border>
						<Rectangle SnapsToDevicePixels="true" Margin="0" Stroke="Black" StrokeDashArray="1 2" StrokeThickness="1"/>
					</Border>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	<LinearGradientBrush x:Key="ExpanderArrowFill" EndPoint="0,1" StartPoint="0,0">
		<GradientStop Color="White" Offset="0"/>
		<GradientStop Color="#FFBFBFBF" Offset="0.5"/>
		<GradientStop Color="#FF878787" Offset="1"/>
	</LinearGradientBrush>
	<LinearGradientBrush x:Key="ExpanderArrowHoverFill" EndPoint="0,1" StartPoint="0,0">
		<GradientStop Color="#FFF0F8FE" Offset="0"/>
		<GradientStop Color="#FFE0F3FE" Offset="0.3"/>
		<GradientStop Color="#FF6FA7C5" Offset="1"/>
	</LinearGradientBrush>
	<LinearGradientBrush x:Key="ExpanderArrowPressedFill" EndPoint="0,1" StartPoint="0,0">
		<GradientStop Color="#FFDCF0FA" Offset="0"/>
		<GradientStop Color="#FFC5E6F7" Offset="0.2"/>
		<GradientStop Color="#FF5690D0" Offset="1"/>
	</LinearGradientBrush>
	<Style x:Key="ExpanderDownHeaderStyle" TargetType="{x:Type ToggleButton}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type ToggleButton}">
					<Border Padding="{TemplateBinding Padding}">
						<StackPanel SnapsToDevicePixels="False" Background="Transparent" Orientation="Horizontal">
							<ContentPresenter SnapsToDevicePixels="True" RecognizesAccessKey="True" d:LayoutOverrides="GridBox" VerticalAlignment="Center" Margin="0,0,0,0"/>
							<Path SnapsToDevicePixels="false" x:Name="arrow" Stroke="#666" StrokeThickness="2" Data="M 1,1.5 L 4.5,5 L 8,1.5" VerticalAlignment="Center" Margin="5,0,0,0" RenderTransformOrigin="0.5,0.5">
								<Path.RenderTransform>
									<TransformGroup>
										<ScaleTransform ScaleX="1" ScaleY="1"/>
										<SkewTransform AngleX="0" AngleY="0"/>
										<RotateTransform Angle="180"/>
										<TranslateTransform X="0" Y="0"/>
									</TransformGroup>
								</Path.RenderTransform>
							</Path>
						</StackPanel>
					</Border>
					<ControlTemplate.Triggers>
						<Trigger Property="IsChecked" Value="true">
							<Setter Property="Data" TargetName="arrow" Value="M 1,4.5  L 4.5,1  L 8,4.5"/>
						</Trigger>
						<Trigger Property="IsMouseOver" Value="true">
							<Setter Property="Stroke" TargetName="arrow" Value="#FFF0F0F0"/>
						</Trigger>
						<Trigger Property="IsPressed" Value="true">
							<Setter Property="Stroke" TargetName="arrow" Value="#FF003366"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	<Style x:Key="ExpanderRightHeaderStyle" TargetType="{x:Type ToggleButton}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type ToggleButton}">
					<Border Padding="{TemplateBinding Padding}">
						<Grid SnapsToDevicePixels="False" Background="Transparent">
							<Grid.RowDefinitions>
								<RowDefinition Height="19"/>
								<RowDefinition Height="*"/>
							</Grid.RowDefinitions>
							<Grid>
								<Grid.LayoutTransform>
									<TransformGroup>
										<TransformGroup.Children>
											<TransformCollection>
												<RotateTransform Angle="-90"/>
											</TransformCollection>
										</TransformGroup.Children>
									</TransformGroup>
								</Grid.LayoutTransform>
								<Ellipse HorizontalAlignment="Center" x:Name="circle" VerticalAlignment="Center" Width="19" Height="19" Fill="{DynamicResource ExpanderArrowFill}" Stroke="DarkGray"/>
								<Path SnapsToDevicePixels="false" HorizontalAlignment="Center" x:Name="arrow" VerticalAlignment="Center" Stroke="#666" StrokeThickness="2" Data="M 1,1.5 L 4.5,5 L 8,1.5"/>
							</Grid>
							<ContentPresenter SnapsToDevicePixels="True" HorizontalAlignment="Center" Margin="0,4,0,0" VerticalAlignment="Top" Grid.Row="1" RecognizesAccessKey="True"/>
						</Grid>
					</Border>
					<ControlTemplate.Triggers>
						<Trigger Property="IsChecked" Value="true">
							<Setter Property="Data" TargetName="arrow" Value="M 1,4.5  L 4.5,1  L 8,4.5"/>
						</Trigger>
						<Trigger Property="IsMouseOver" Value="true">
							<Setter Property="Stroke" TargetName="circle" Value="#FF3C7FB1"/>
							<Setter Property="Fill" TargetName="circle" Value="{DynamicResource ExpanderArrowHoverFill}"/>
							<Setter Property="Stroke" TargetName="arrow" Value="#222"/>
						</Trigger>
						<Trigger Property="IsPressed" Value="true">
							<Setter Property="Stroke" TargetName="circle" Value="#FF526C7B"/>
							<Setter Property="StrokeThickness" TargetName="circle" Value="1.5"/>
							<Setter Property="Fill" TargetName="circle" Value="{DynamicResource ExpanderArrowPressedFill}"/>
							<Setter Property="Stroke" TargetName="arrow" Value="#FF003366"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	<Style x:Key="ExpanderUpHeaderStyle" TargetType="{x:Type ToggleButton}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type ToggleButton}">
					<Border Padding="{TemplateBinding Padding}">
						<Grid SnapsToDevicePixels="False" Background="Transparent">
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="19"/>
								<ColumnDefinition Width="*"/>
							</Grid.ColumnDefinitions>
							<Grid>
								<Grid.LayoutTransform>
									<TransformGroup>
										<TransformGroup.Children>
											<TransformCollection>
												<RotateTransform Angle="180"/>
											</TransformCollection>
										</TransformGroup.Children>
									</TransformGroup>
								</Grid.LayoutTransform>
								<Ellipse HorizontalAlignment="Center" x:Name="circle" VerticalAlignment="Center" Width="19" Height="19" Fill="{DynamicResource ExpanderArrowFill}" Stroke="DarkGray"/>
								<Path SnapsToDevicePixels="false" HorizontalAlignment="Center" x:Name="arrow" VerticalAlignment="Center" Stroke="#666" StrokeThickness="2" Data="M 1,1.5 L 4.5,5 L 8,1.5"/>
							</Grid>
							<ContentPresenter SnapsToDevicePixels="True" HorizontalAlignment="Left" Margin="4,0,0,0" VerticalAlignment="Center" Grid.Column="1" RecognizesAccessKey="True"/>
						</Grid>
					</Border>
					<ControlTemplate.Triggers>
						<Trigger Property="IsChecked" Value="true">
							<Setter Property="Data" TargetName="arrow" Value="M 1,4.5  L 4.5,1  L 8,4.5"/>
						</Trigger>
						<Trigger Property="IsMouseOver" Value="true">
							<Setter Property="Stroke" TargetName="circle" Value="#FF3C7FB1"/>
							<Setter Property="Fill" TargetName="circle" Value="{DynamicResource ExpanderArrowHoverFill}"/>
							<Setter Property="Stroke" TargetName="arrow" Value="#222"/>
						</Trigger>
						<Trigger Property="IsPressed" Value="true">
							<Setter Property="Stroke" TargetName="circle" Value="#FF526C7B"/>
							<Setter Property="StrokeThickness" TargetName="circle" Value="1.5"/>
							<Setter Property="Fill" TargetName="circle" Value="{DynamicResource ExpanderArrowPressedFill}"/>
							<Setter Property="Stroke" TargetName="arrow" Value="#FF003366"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	<Style x:Key="ExpanderLeftHeaderStyle" TargetType="{x:Type ToggleButton}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type ToggleButton}">
					<Border Padding="{TemplateBinding Padding}">
						<Grid SnapsToDevicePixels="False" Background="Transparent">
							<Grid.RowDefinitions>
								<RowDefinition Height="19"/>
								<RowDefinition Height="*"/>
							</Grid.RowDefinitions>
							<Grid>
								<Grid.LayoutTransform>
									<TransformGroup>
										<TransformGroup.Children>
											<TransformCollection>
												<RotateTransform Angle="90"/>
											</TransformCollection>
										</TransformGroup.Children>
									</TransformGroup>
								</Grid.LayoutTransform>
								<Ellipse HorizontalAlignment="Center" x:Name="circle" VerticalAlignment="Center" Width="19" Height="19" Fill="{DynamicResource ExpanderArrowFill}" Stroke="DarkGray"/>
								<Path SnapsToDevicePixels="false" HorizontalAlignment="Center" x:Name="arrow" VerticalAlignment="Center" Stroke="#666" StrokeThickness="2" Data="M 1,1.5 L 4.5,5 L 8,1.5"/>
							</Grid>
							<ContentPresenter SnapsToDevicePixels="True" HorizontalAlignment="Center" Margin="0,4,0,0" VerticalAlignment="Top" Grid.Row="1" RecognizesAccessKey="True"/>
						</Grid>
					</Border>
					<ControlTemplate.Triggers>
						<Trigger Property="IsChecked" Value="true">
							<Setter Property="Data" TargetName="arrow" Value="M 1,4.5  L 4.5,1  L 8,4.5"/>
						</Trigger>
						<Trigger Property="IsMouseOver" Value="true">
							<Setter Property="Stroke" TargetName="circle" Value="#FF3C7FB1"/>
							<Setter Property="Fill" TargetName="circle" Value="{DynamicResource ExpanderArrowHoverFill}"/>
							<Setter Property="Stroke" TargetName="arrow" Value="#222"/>
						</Trigger>
						<Trigger Property="IsPressed" Value="true">
							<Setter Property="Stroke" TargetName="circle" Value="#FF526C7B"/>
							<Setter Property="StrokeThickness" TargetName="circle" Value="1.5"/>
							<Setter Property="Fill" TargetName="circle" Value="{DynamicResource ExpanderArrowPressedFill}"/>
							<Setter Property="Stroke" TargetName="arrow" Value="#FF003366"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	<Style x:Key="GadgetExpander" TargetType="{x:Type Expander}">
		<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
		<Setter Property="Background" Value="Transparent"/>
		<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
		<Setter Property="VerticalContentAlignment" Value="Stretch"/>
		<Setter Property="BorderBrush" Value="Transparent"/>
		<Setter Property="BorderThickness" Value="1"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Expander}">
					<Border SnapsToDevicePixels="true" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3">
						<DockPanel>
							<ToggleButton FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" FocusVisualStyle="{StaticResource ExpanderHeaderFocusVisual}" Margin="1" MinHeight="0" MinWidth="0" x:Name="HeaderSite" Style="{StaticResource ExpanderDownHeaderStyle}" IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}" ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}" DockPanel.Dock="Top"/>
							<ContentPresenter Focusable="false" Visibility="Collapsed" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" x:Name="ExpandSite" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" DockPanel.Dock="Bottom" ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.CanContentScroll="False"/>
						</DockPanel>
					</Border>
					<ControlTemplate.Triggers>
						<Trigger Property="IsExpanded" Value="true">
							<Setter Property="Visibility" TargetName="ExpandSite" Value="Visible"/>
						</Trigger>
						<Trigger Property="ExpandDirection" Value="Right">
							<Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Right"/>
							<Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Left"/>
							<Setter Property="Style" TargetName="HeaderSite" Value="{StaticResource ExpanderRightHeaderStyle}"/>
						</Trigger>
						<Trigger Property="ExpandDirection" Value="Up">
							<Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Top"/>
							<Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Bottom"/>
							<Setter Property="Style" TargetName="HeaderSite" Value="{StaticResource ExpanderUpHeaderStyle}"/>
						</Trigger>
						<Trigger Property="ExpandDirection" Value="Left">
							<Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Left"/>
							<Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Right"/>
							<Setter Property="Style" TargetName="HeaderSite" Value="{StaticResource ExpanderLeftHeaderStyle}"/>
						</Trigger>
						<Trigger Property="IsEnabled" Value="false">
							<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>	    
</ResourceDictionary>